package com.xnyzc.lhy.finance.service.fegin.cp.fallback;

import com.alibaba.fastjson.JSONObject;
import com.xnyzc.lhy.resource.common.cp.dto.SingleQueryParam;
import com.xnyzc.lhy.resource.common.cp.dto.SingleTradeResult;
import com.xnyzc.lhy.resource.common.cp.dto.TransactionInfo;
import com.xnyzc.lhy.finance.service.fegin.cp.IFinanceTradeService;
import com.xnyzc.lhy.resource.common.cp.penum.CPErrorCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class TradeServiceFallback implements IFinanceTradeService {
    /**
     * 单笔代付
     * @param transactionInfo
     * @return
     */
    @Override
    public JSONObject singleTrade(TransactionInfo transactionInfo) {
        return this.convertJsonObject(new SingleTradeResult(CPErrorCode.cpResourceServiceError));
    }

    /**
     * 单笔代付查询
     * @param singleQueryParam 代付查询信息
     * @return
     */
    @Override
    public SingleTradeResult singleQuery(SingleQueryParam singleQueryParam){
        return new SingleTradeResult(CPErrorCode.cpResourceServiceError);
    }

    /**
     * 处理返回结果
     */
    private JSONObject convertJsonObject(SingleTradeResult singleTradeResult) {
        JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(singleTradeResult));
        return jsonObject;
    }
}
